package com.csxh.bookstore.bean;

import java.io.Serializable;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

public class OrderDetail  implements Serializable {

	private Integer id;
	
	//private Integer orderId;
	private Order order;
	
	private Set<Item> itemSet=new HashSet<Item>();

	public void add(Item item) {
		
		this.itemSet.add(item);
		item.setDetail(this);
		
	}
	
	public void setItemSet(Set<Item> itemSet) {
		this.itemSet = itemSet;
		
	}
	
	public Set<Item> getItemSet() {
		return itemSet;
	}
	
	private Date    createDate;
	
	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}
	
	public Date getCreateDate() {
		return createDate;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public void setOrder(Order order) {
		this.order = order;
	}
	
	public Order getOrder() {
		return order;
	}
	
	public Integer getOrderId() {
		return order.getId();
	}

	public void setOrderId(Integer orderId) {
		this.order.setId(orderId);
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		OrderDetail other = (OrderDetail) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		return true;
	}

	
}
